package com.cn.demo.springboot.shiro.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.cn.demo.springboot.shiro.entity.Permission;

@Mapper
public interface PermissionMapper {

	@Select("select * from sys_Permission where permission_Code = #{fuckyou}")
	Permission findByPermissionCode(String permissionCode);
	
	@Update("update sys_Permission set permission_Name = #{permissionName},menu_Code=#{menuCode}")
	void updatePermission(Permission permission);
	
	@Select("select * from sys_Permission")
	List<Permission> findAll();
	
	@Insert("insert into sys_permission (permission_Name,permission_Code,menu_Code) value (#{permissionName},#{permissionCode},#{menuCode})")
	void insertPermission(Permission permission);
	
	@Delete("Delete from sys_permission where permission_id = #{permissionId}")
	void delPermission(Permission permission);
	
	@Select("SELECT * from sys_permission p ,sys_role_permission rp WHERE rp.roleId = #{roleId} AND rp.permission_Id = p.permission_Id")
	public List<Permission> findPermissionByRole(Integer roleId);
	
	
	
}
